# -*- coding: utf-8 -*-
# @Time    : 2024/5/16 11:05
# @Author  : Alvin
# @File    : redis_service.py
# myproject/redis_service.py

from scrapy import settings
from .redis_client import RedisClient
import os
GLOBAL_HOST = os.getenv('GLOBAL_HOST', 'localhost')

class RedisService:
    def __init__(self):
        self.redis_client = RedisClient(
            host=GLOBAL_HOST,
            port=6379,
            db=4
        )

    # @classmethod
    # def from_crawler(cls, crawler):
    #     instance = cls()
    #     # 将 Redis 服务实例保存到 crawler 中，以便其他组件使用
    #     crawler.redis_service = instance
    #     return instance
    #
    # def spider_opened(self, spider):
    #     # 当爬虫被打开时执行的操作
    #     spider.logger.info('RedisService opened: %s' % spider.name)